package com.gdziarmaga.webshop.core.utils;

import javax.annotation.PostConstruct;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;

import com.gdziarmaga.webshop.book.model.Book;
import com.gdziarmaga.webshop.utils.filtering.BaseFilter;
import com.gdziarmaga.webshop.utils.filtering.FilterComparisonType;
import com.gdziarmaga.webshop.utils.filtering.FilterField;
import com.gdziarmaga.webshop.utils.filtering.GenericFilter;


@Scope("request")
public class BookFilterBean extends BaseFilter {
    /**
	 * 
	 */
	private static final long serialVersionUID = -7200209860145222036L;
	private FilterField<String> isbn;
    //TODO what with TITLE!!??
    private FilterField<String> title;
    private FilterField<Integer> issue_year;
    private FilterField<String> publisher;
    private FilterField<String> section;
    private FilterField<Float> startPrice;
    private FilterField<Float> endPrice;

    
    //TODO to chyba nie jest portzebne
    @Autowired
//    private SelectorUtils selectorUtils;

    @SuppressWarnings("unchecked")
    @PostConstruct
    public void init() {
        isbn = (FilterField<String>) addFilterField(new FilterField<String>(null, Book.ISBN, FilterComparisonType.LIKE_CASE_INSENSITIVE));
//        title = (FilterField<String>) addFilterField(new FilterField<String>(null, User.FIRSTNAME, FilterComparisonType.LIKE_CASE_INSENSITIVE));
        issue_year = (FilterField<Integer>) addFilterField(new FilterField<String>(null, Book.ISSUE_YEAR, FilterComparisonType.LIKE));
        publisher = (FilterField<String>) addFilterField(new FilterField<String>(null, Book.PUBLISHER, FilterComparisonType.LIKE_CASE_INSENSITIVE));
        section = (FilterField<String>) addFilterField(new FilterField<String>(null, Book.SECTION, FilterComparisonType.LIKE_CASE_INSENSITIVE));
        startPrice = (FilterField<Float>) addFilterField(new FilterField<Float>(null, Book.PRICE, FilterComparisonType.GREATER_EQUAL));
        endPrice = (FilterField<Float>) addFilterField(new FilterField<Float>(null, Book.PRICE, FilterComparisonType.LESS_EQUAL));
    }

   
    public FilterField<String> getIsbn() {
		return isbn;
	}


	public void setIsbn(FilterField<String> isbn) {
		this.isbn = isbn;
	}


	public FilterField<String> getTitle() {
		return title;
	}


	public void setTitle(FilterField<String> title) {
		this.title = title;
	}


	public FilterField<Integer> getIssue_year() {
		return issue_year;
	}


	public void setIssue_year(FilterField<Integer> issue_year) {
		this.issue_year = issue_year;
	}


	public FilterField<String> getPublisher() {
		return publisher;
	}


	public void setPublisher(FilterField<String> publisher) {
		this.publisher = publisher;
	}


	public FilterField<String> getSection() {
		return section;
	}


	public void setSection(FilterField<String> section) {
		this.section = section;
	}


	public FilterField<Float> getStartPrice() {
		return startPrice;
	}


	public void setStartPrice(FilterField<Float> startPrice) {
		this.startPrice = startPrice;
	}


	public FilterField<Float> getEndPrice() {
		return endPrice;
	}


	public void setEndPrice(FilterField<Float> endPrice) {
		this.endPrice = endPrice;
	}


//	public SelectorUtils getSelectorUtils() {
//		return selectorUtils;
//	}
//
//
//	public void setSelectorUtils(SelectorUtils selectorUtils) {
//		this.selectorUtils = selectorUtils;
//	}


	public void clean() {
        isbn.setValue(null);
        title.setValue(null);
        issue_year.setValue(null);
        publisher.setValue(null);
        section.setValue(null);
        startPrice.setValue(null);
        endPrice.setValue(null);
    }
}
